<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>充值</title>
</head>
<body>
    <input type="text" value="500" id="input" placeholder="请输入金额">
    <button id="btn">充值</button>
    <script>
        // 监听按钮被点击，先获取按钮，通过id查找元素
        btn.onclick = function () {
            var input = document.getElementById('input').value;
            // console.log(input);
            alert('大冤种充值成功！金额¥'+input+'元')
        }
    </script>
</body>
</html>